package com.web;


import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@WebServlet("/servletImpl")
public class servletImpl implements Servlet {


    @Override
    public void init(ServletConfig servletConfig) throws ServletException {

    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {

        HttpServletRequest request = (HttpServletRequest) servletRequest;
        String method = request.getMethod();

        if("GET".equals(method)){
            String name = request.getParameter("name");
            System.out.println("name:"+name);
        }
        if("POST".equals(method)){
            System.out.println("POST");
            String name = request.getParameter("name");
            System.out.println("name:"+name);
        }
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {

    }
}
